home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / vision / povray / math / helix.pov < prev    next >
Text File  |  1995-11-25  |  3KB  |  142 lines

  1. // Persistence Of Vision raytracer version 2.0 sample file.
  2.  
  3. // Sample quartic file
  4. // by Alexander Enzmann
  5.  
  6. #include "shapes.inc"
  7. #include "colors.inc"
  8. #include "textures.inc"
  9. #include "shapesq.inc"
  10.  
  11. /*
  12.    Approximation to the helix z = arctan(y/x).
  13.  
  14.    The helix can be approximated with an algebraic equation (kept to the
  15.    range of a quartic) with the following steps:
  16.  
  17.       tan(z) = y/x   =>  sin(z)/cos(z) = y/x   =>
  18.  
  19.    (1) x sin(z) - y cos(z) = 0
  20.  
  21.    Using the taylor expansions for sin, cos about z = 0,
  22.  
  23.       sin(z) = z - z^3/3! + z^5/5! - ...
  24.       cos(z) = 1 - z^2/2! + z^6/6! - ...
  25.  
  26.    Throwing out the high order terms, the expression (1) can be written as:
  27.  
  28.       x (z - z^3/6) - y (1 + z^2/2) = 0, or
  29.  
  30.   (2) -1/6 x z^3 + x z + 1/2 y z^2 - y = 0
  31.  
  32.   This helix (2) turns 90 degrees in the range 0 <= z <= sqrt(2)/2.  By using
  33.   scale <2 2 2>, the helix defined below turns 90 degrees in the range
  34.   0 <= z <= sqrt(2) = 1.4042.
  35. */
  36.  
  37. #declare Red_Helix =
  38. object {
  39.    Helix
  40.    texture {
  41.       pigment { Red }
  42.       finish { phong 1.0 }
  43.       /* scale <1, 1.4142, 1> */
  44.    }
  45. }
  46.  
  47. #declare Green_Helix =
  48. object { 
  49.    Helix
  50.    texture {
  51.       pigment { Green }
  52.       finish { phong 1.0 }
  53.       /* scale <1, 1.4142, 1> */
  54.    }
  55. }
  56.  
  57. // Glue a bunch of pieces together to make one long helix. 
  58.  
  59. object {
  60.    Green_Helix
  61.    translate -4.2426*z
  62.    rotate 160*z
  63.    rotate -90*x
  64.    translate <0, -2, 5>
  65. }
  66.  
  67. object {
  68.    Red_Helix
  69.    translate -2.8284*z
  70.    rotate 70*z
  71.    rotate -90*x
  72.    translate <0, -2, 5>
  73. }
  74.  
  75. object {
  76.    Green_Helix
  77.    translate -1.4142*z
  78.    rotate 160*z
  79.    rotate -90*x
  80.    translate <0, -2, 5>
  81. }
  82.  
  83. object {
  84.    Red_Helix
  85.    rotate 70*z
  86.    rotate -90*x
  87.    translate <0, -2, 5>
  88. }
  89.  
  90. object {
  91.    Green_Helix
  92.    translate 1.4142*z
  93.    rotate 160*z
  94.    rotate -90*x
  95.    translate <0, -2, 5>
  96. }
  97.  
  98. object {
  99.    Red_Helix
  100.    translate 2.8284*z
  101.    rotate 70*z
  102.    rotate -90*x
  103.    translate <0, -2, 5>
  104. }
  105.  
  106. object {
  107.    Green_Helix
  108.    translate 4.2426*z
  109.    rotate 160*z
  110.    rotate -90*x
  111.    translate <0, -2, 5>
  112. }
  113.  
  114. object {
  115.    Red_Helix
  116.    translate 5.6569*z
  117.    rotate 70*z
  118.    rotate -90*x
  119.    translate <0, -2, 5>
  120. }
  121.  
  122. object {
  123.    Green_Helix
  124.    translate 7.0711*z
  125.    rotate 160*z
  126.    rotate -90*x
  127.    translate <0, -2, 5>
  128. }
  129.  
  130.  
  131. camera {
  132.    location  <0.0, 0.0, -10.0>
  133.    direction <0.0, 0.0, 1.0>
  134.    up        <0.0, 1.0, 0.0>
  135.    right     <4/3, 0.0, 0.0>
  136. }
  137.  
  138. // Toss in a couple of light sources. 
  139. light_source { <200, 100, -300> colour red 1.0 green 1.0 blue 1.0 }
  140.  
  141. light_source { <-200, 100, -300> colour red 1.0 green 1.0 blue 1.0 }
  142.